#include <stdio.h>
#include <stdlib.h>
int findxiny(char[],char[]);
#define MAGIC_BIG 1024
int main ()
{
  char s[MAGIC_BIG];
  char s2[MAGIC_BIG];
  for (int i=0; i<MAGIC_BIG; i++)
    s[i]=s2[i]='\0';
  printf("string 1 : ?>");
  char in='1';
  
  int i =0;
  while ((in!=EOF) && (in != '\n'))
    {
	 in=s[i]=getchar();
	 i++;
	 if (i>MAGIC_BIG)
	   {
		printf("\n string too big \n");
		return -1;
	   }
    }
  
  printf("string 2 : ?>");
  i=0;
  in = '1';
  while ((in!=EOF) && (in != '\n'))
    {
	 in=s2[i]=getchar();
	 i++;
	 if (i>MAGIC_BIG)
	   {
		printf("\n delim string too big \n");
		return -1;
	   }
    }
    
  printf("location %d : ", findxiny(s2,s));
  return (0);
} 

/** goners MUST BE a null terminated string*/
int findxiny(char y[], char x[])
{
  for (int i=0; x[i]!='\0'; i++)
    {
	 int bm=0;
	 int j =0;
	 while(bm==0)
	   {
		if (x[i]!=y[j])
		  bm=1;
		if (x[i]==y[j])
		  j++;
		if(y[j]=='\0')
		  return i;
	   }
    }
  return -1;
}


